<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
    <link rel="stylesheet" href="//static/css/bootstrap.min.css">
    <link href="//static/plugins/bootstrap-table/bootstrap-table.css" rel="stylesheet">
    <link href="//static/css/style.css" rel="stylesheet">
    <link rel="stylesheet" href="//static/css/public.css">
    <link rel="stylesheet" href="//static/css/font-awesome.min.css">
    <!-- jquery 提示插件css -->
    <link href="//static/plugins/bootstrap-tree/bootstrap-treeview.css" rel="stylesheet">
    <!--bootstrap-tree插件-->
    <link href="//static/plugins/toastr.min.css" rel="stylesheet">
    <script type="text/javascript"
            src="http://api.map.baidu.com/api?v=2.0&ak=1t51luG5BxGrGLW4y9zu3sS6Tz8O3vAG"></script>
    <title>设备管理</title>
</head>
<body style="background-color:#eee">
<div id="app" style="margin-top: 10px">
    <div class="float-clear">
        <div class="float-left contentBox border-all" style="width:99%;margin: 0 0.5%;">
            <div class="content-title border-bottom">
                    <span>站点管理</span>
                </div>
            <div class="content-center">
                <div class="ibox-content" style="position: relative;">
                     <button class="btn btn-default pull-right my-btn my-btn-remove" onclick="deleteBtnClick()">删除</button>
                    <button class="btn btn-default pull-right my-btn my-btn-pencil" onclick="editBenClick()">编辑</button>
                    <button class="btn btn-default pull-right my-btn my-btn-add" onclick="addBtnClick()">添加</button>
                    <button class="btn btn-default my-btn my-search-btn my-btn-search"
                        style="top:15px; left: 245px;">查询
                    </button>
                    <table id="table"
                           data-toggle="table"
                           data-toolbar=".toolbar"
                           data-pagination="true"
                           data-maintain-selected="true"
                           data-search="true"
                           data-show-refresh="false"
                           data-search-align="left"
                           data-toolbar-align="right">
                        <thead>
                        <tr>
                            <th data-field="id"></th>
                            <th data-field="name">设施名称</th>
                            <th data-field="code">编号</th>
                            <th data-field="status">状态</th>
                            <th data-field="lng">经度</th>
                            <th data-field="lat">纬度</th>
                            <th data-field="start_time">启动时间</th>
                            <th data-field="day">运行天数</th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 主要的脚本 -->
<script src="//static/js/jquery-3.1.1.min.js"></script>
<script src="//static/js/bootstrap.min.js"></script>
<script src="//static/plugins/bootstrap-table/bootstrap-table.js"></script>
<script src="//static/plugins/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
<script src="//static/js/vue.min.js"></script>
<!-- Toastr -->
<script src="//static/plugins/toastr/toastr.min.js"></script>
<!--bootstrap-tree插件-->
<script src="//static/plugins/bootstrap-tree/bootstrap-treeview.js"></script>
<script type="text/javascript">
    var vm = new Vue({
        el: '#app',
        data: {
            oldIndex: 1,
            tabIndex: 0
        },
    });
    //boot table
    var $table = $("#table");
    var tableList = [];
    function getTableList(){
        $.ajax({
                url: '/core/facility/get_all/',
                type: 'POST',
                dataType: "json",
                headers: {
                    "token": localStorage.getItem("token")
                },
                data: {},
                async: true,
                contentType: "application/json",
                success: function (response) {
                    if (response && response.success == 1) {
                        tableList=response.data;
                        $table.bootstrapTable('load',tableList);
                    } else {
                        toastr.info(response.error_msg);
                    }
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    switch (XMLHttpRequest.status) {
                        case(500):
                            toastr.info('服务器系统内部错误');
                            break;
                        case(403):
                            toastr.info("无权限执行此操作");
                            break;
                        case(408):
                            toastr.info("请求超时");
                            break;
                        default:
                            toastr.info(XMLHttpRequest.responseText);
                    }
                }
            });
    }
    //点击跳转到指定详情页面
    function jumpDetail() {
        var item = {
            name: '详情页面',
            url: '/core/secondSupply/equipmentDetail'
        };
        location.href=item.url;
    }

    $(document).ready(function () {
        $(".contentBox").css({"height": $(document.body).height() - 20});
        $(window).resize(function () {//当浏览器大小变化时
            $(".contentBox").css({"height": $(document.body).height() - 20})
        });
        //获取table数据
        getTableList();
    })
    //    标题的的切换
</script>
</body>
</html>
